To run: place qog_bas_cs_jan21.dta and sort11v3.dta in a suitable working directory. Run Numerical_Illustration.R without modification (note: graphical output assumes OS X).

Tested with: 
R 4.0.3 Catalina
MacBook Pro (M1, 2020), 16 GB RAM
macOS 11.2 
haven package in R, version 2.4.0
latex2exp package in R, version 0.5.0
RColorBrewer package in R, version 1.1-2

Details below:
(Note: quartz(), quartz.save() functions only run in Mac OS environment and are used to reproduce the exact figures. For other environments, please ignore this command and refer to the generated plots.)

--- QoG simulation ---

Script:
 - Simcode_Qog.R - replicates Figure 1, Table 1 (left column), and in-text numbers reported in Section 3.2 regarding QoG simulation. 
		 
Outputs:
 - SIM25000_qog.csv - raw simulation output
 - qog-figure.pdf - Figure 1
 - Simcode_Qog.Rout - output from batch mode. Output for Table 1 and in-text numbers (expected_table_qog, prop_table_qog) included here.

Input:
 - qog_bas_cs_jan21.dta available at: https://www.qogdata.pol.gu.se/data/qog_std_cs_jan21.dta (last accessed Jun 25, 2021)
   - Citation: Teorell, Jan, Aksel Sundstrom, Saren Holmberg, Bo Rothstein, Natalia Alvarado Pachon & Cem Mert Dalli. 2021. The Quality of Government Standard Dataset, version Jan21. University of Gothenburg: The Quality of Government Institute, http://www.qog.pol.gu.se doi:10.18157/qogstdjan21

---- State Failure simulation --

Script:
 - Simcode_Statefailure.R - replicates Figure 2, Table 1 (right column), and in-text numbers (expected_table_sf, prop_table_sf) reported in Section 3.2 regarding State Failure simulation. 
  - WARNING: this may take over 24 hours to run on a personal computer. It may be advisable to change the sims variable in line 24 to be a smaller number. The output can be crossreferenced to the first rows of SIM25000_SF.csv.

Input:
 - sort11v3.dta - available at https://doi.org/10.7 910/DVN/BS4236 (last accessed Jun 25, 2021)
   - Citation: King, Gary; Zeng, Langche, 2007, "Replication data for: Improving Forecasts of State Failure", https://doi.org/10.7910/DVN/BS4236, Harvard Dataverse, V4, UNF:3:CEsbEgPxbxExfYuh2NWwWQ== [fileUNF]

Outputs:
 - SIM25000_SF.csv - raw simulation output
 - sf-figure.pdf - Figure 2
 - Simcode_Statefailure.Rout - output from batch mode. Output for Table 1 and in-text numbers (expected_table_sf, prop_table_sf) included here.


----- Numerical Illustration ----

Script:
 - Numerical_Illustration.R -- replicates Figure 3, 4 and 5 and in-text numbers in Supporting Information A

Input:
 - None.

Outputs:
 - figure3.pdf - Figure 3
 - figure4-1.pdf, figure4-1.pdf - Figure 4
 - figure5.pdf - Figure 5
 - Numerical_Illustration.Rout -- output from batch mode. Output for in-text numbers included here.

